RM	= rm -f
CC	= gcc
CFLAGS	= -Isrc/ -Isrc/libs -Isrc/task -Wall
BINDIR	= bin
OBJDIR	= obj
TARGET	= $(BINDIR)/server
OBJS	= src/main.o src/task/msg_loop.o src/task/keep_live.o src/task/read_tun.o src/libs/tools.o
.PHONY: build
build: $(BINDIR) $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) $^ -o $@ -lpthread -g

$(OBJS):%.o:%.c
	$(CC) -c $(CFLAGS) $^ -o $@

$(BINDIR):
	mkdir $@

.PHONY: clean
clean:
	$(RM) $(OBJS)
	$(RM) -r $(BINDIR)

.PHONY: run
run: build
	sudo ./$(TARGET)
